// Water Quality MCP Server Implementation
// 水质监测MCP服务器实现
const MCPServer = require('./MCPServer');
const WaterQualityDataSource = require('./WaterQualityDataSource');
const ChemicalDosageDataSource = require('./ChemicalDosageDataSource');

class WaterQualityMCPServer extends MCPServer {
  constructor(port) {
    super('WaterQuality', port);
    this.registerDataSource('waterQuality', new WaterQualityDataSource());
    this.registerDataSource('chemicalDosage', new ChemicalDosageDataSource());
  }

  // Get water quality data
  // 获取水质数据
  getWaterQualityData() {
    return this.getData('waterQuality');
  }

  // Get chemical dosage data
  // 获取化学加药数据
  getChemicalDosageData() {
    return this.getData('chemicalDosage');
  }

  // Control chemical dosage pumps
  // 控制化学加药泵
  controlChemicalDosage(command) {
    return this.sendCommand('chemicalDosage', command);
  }

  // Start the server
  // 启动服务器
  start() {
    super.start();
    console.log('Water Quality MCP Server initialized with data sources');
    console.log('水质监测MCP服务器已初始化数据源');
  }
}

// Export for use in other modules
// 导出以供其他模块使用
module.exports = WaterQualityMCPServer;

// Start server if this file is run directly
// 如果直接运行此文件则启动服务器
if (require.main === module) {
  const server = new WaterQualityMCPServer(3001);
  server.start();
  
  // Example of how to access data
  // 访问数据的示例
  setInterval(() => {
    console.log('Water Quality Data:', server.getWaterQualityData());
    console.log('水质数据:', server.getWaterQualityData());
    console.log('Chemical Dosage Data:', server.getChemicalDosageData());
    console.log('化学加药数据:', server.getChemicalDosageData());
  }, 10000);
}